package com.itheima.web;
/*
* 用户退出
* */
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/logoutServlet")
public class LogoutServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        /*退出页面
        * 点击退出页面后
        * 1.清除用户信息，跳转页面
        * 信息存放在服务器端，页面跳转使用重定向，因为页面发生变换
        * */
        //1.从session中移除用户信息
        request.getSession().removeAttribute("manager");
        /*request.getSession().removeAttribute("manager");
        response.sendRedirect(request.getContextPath()+"/login.jsp");*/
        //2.页面跳转，跳转到登录页面 采用重定向
        response.sendRedirect(request.getContextPath()+"/login.jsp");






    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
}
